package com.wimcorp.magic.dataloader.abilities;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.user.client.ui.TextBox;
import com.wimcorp.magic.data.AbilityData;
import com.wimcorp.magic.input.AbilityInput;

public class AddCounterWidget extends AbilityWidget {

	private TextBox power;
	private TextBox toughness;

	public AddCounterWidget(AbilityInput ability) {
		super(ability);
	}

	protected void initAbilityFields() {
		super.initAbilityFields();
		power = new TextBox();
		toughness = new TextBox();
		addInputTextBox("Power", power, 0);
		addInputTextBox("Toughness", toughness, 1);
	}

	public JSONObject getAbilityConfig() {
		JSONObject config = super.getAbilityConfig();
		config.put("power", new JSONString(power.getValue()));
		config.put("toughness", new JSONString(toughness.getValue()));
		return config;
	}

	public void load(AbilityData abilityData) {
		super.load(abilityData);
		JSONObject config = (JSONObject) JSONParser.parseLenient(abilityData.getConfig());
		power.setValue(toString(config.get("power")));
		toughness.setValue(toString(config.get("toughness")));

	}

}
